package study.domain;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Email;
import javax.validation.constraints.Max;
import javax.validation.constraints.NotNull;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

@Component
@ConfigurationProperties(prefix="person")
@Validated
public class Person {
    //@Value("${person.id}")
    @Max(9)
    private int id;
    //@Value("${person.name}")
    private String name;
    //@Value("${person.hobby}")
    private List hobby;
    //@Value("${person.family}")
    private String[] family;
    //@Value("#{${person.map}}")
    private Map map;

    //@NotNull
    private String firstName;


    //@Email
    private String email;

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getFirstName() {
        return firstName;
    }

    public void setFirstName(String firstName) {
        this.firstName = firstName;
    }

    @Autowired
    private Pet pet;

    @Override
    public String toString() {
        return "Person{" +
                "id=" + id +
                ", name='" + name + '\'' +
                ", hobby=" + hobby +
                ", family=" + Arrays.toString(family) +
                ", map=" + map +
                ", pet=" + pet +
                '}';
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }
    //
    public String getName() {
        return name;
    }
    //
    public void setName(String name) {
        this.name = name;
    }
    //
    public List getHobby() {
        return hobby;
    }
    //
    public void setHobby(List hobby) {
        this.hobby = hobby;
    }
    //
    public String[] getFamily() {
        return family;
    }
    //
    public void setFamily(String[] family) {
        this.family = family;
    }
    //
    public Map getMap() {
        return map;
    }
    //
    public void setMap(Map map) {
        this.map = map;
    }
    //
    public Pet getPet() {
        return pet;
    }
    //
    public void setPet(Pet pet) {
        this.pet = pet;
    }
}
